import 'package:freezed_annotation/freezed_annotation.dart';

part 'category_model.freezed.dart';
part 'category_model.g.dart';

@freezed
class CategoryFirstLevel with _$CategoryFirstLevel {
  const factory CategoryFirstLevel({
    @Default([]) List<CategoryFirstLevelModel> result,
  }) = _CategoryFirstLevel;

  /// 正确解析 JSON
  factory CategoryFirstLevel.fromJson(Map<String, dynamic> json) => _$CategoryFirstLevelFromJson(json);
}

@freezed
class CategoryFirstLevelModel with _$CategoryFirstLevelModel {
  const factory CategoryFirstLevelModel({
    required String id,
    required String name,
    required String icon,
  }) = _CategoryFirstLevelModel;

  /// 正确解析单个数组项
  factory CategoryFirstLevelModel.fromJson(Map<String, dynamic> json) => _$CategoryFirstLevelModelFromJson(json);
}

/// 二級分類
@freezed
class CategorySecondsLevel with _$CategorySecondsLevel {
  const factory CategorySecondsLevel({
    @Default([]) List<CategorySecondsLevelChildrenModel> children,
  }) = _CategorySecondsLevel;

  factory CategorySecondsLevel.fromJson(Map<String, dynamic> json) => _$CategorySecondsLevelFromJson(json);
}

@freezed
class CategorySecondsLevelChildrenModel with _$CategorySecondsLevelChildrenModel {
  const factory CategorySecondsLevelChildrenModel({
    required String id,
    required String name,
    required String picture,
    @Default([]) List<CategorySecondsLevelChildrenGoodsModel> goods,
  }) = _CategorySecondsLevelChildrenModel;

  factory CategorySecondsLevelChildrenModel.fromJson(Map<String, dynamic> json) => _$CategorySecondsLevelChildrenModelFromJson(json);
}

@freezed
class CategorySecondsLevelChildrenGoodsModel with _$CategorySecondsLevelChildrenGoodsModel {
  const factory CategorySecondsLevelChildrenGoodsModel({
    required String id,
    required String name,
    required int orderNum,
    required String picture,
    required String price,
  }) = _CategorySecondsLevelChildrenGoodsModel;

  factory CategorySecondsLevelChildrenGoodsModel.fromJson(Map<String, dynamic> json) => _$CategorySecondsLevelChildrenGoodsModelFromJson(json);
}



